import request from '@/utils/request.js'

// 登录请求接口
export const login = data => {
  return request({
    method: 'POST',
    url: '/app/v1_0/authorizations',
    data
  })
}

// 获取短信验证码接口
export const sendSmsCode = mobile => {
  return request({
    method: 'GET',
    url: `/app/v1_0/sms/codes/${mobile}`
  })
}
// 获取用户信息
export const userMessage = () => {
  return request({
    method: 'GET',
    url: '/app/v1_0/user'
  })
}
// 获取文章频道列表
export const getChannels = () => {
  return request({
    method: 'GET',
    url: '/app/v1_0/user/channels'
  })
}

// 获取文章列表内容
export const getArticles = (params) => {
  return request({
    method: 'GET',
    url: '/app/v1_1/articles',
    params
  })
}
// 获取全部频道列表
export const getAllChannels = () => {
  return request({
    method: 'GET',
    url: '/app/v1_0/channels'
  })
}

// 批量修改用户频道（线上存储）
export const onLineStorage = (data) => {
  return request({
    method: 'PATCH',
    url: '/app/v1_0/user/channels',
    data
  })
}

// 批量删除用户频道（线上存储）
export const deleteLineStorage = (id) => {
  return request({
    method: 'DELETE',
    url: ` /app/v1_0/user/channels/${id}`
  })
}

// 联想建议接口   suggestion
export const getSuggestion = (params) => {
  return request({
    method: 'GET',
    url: '/app/v1_0/suggestion',
    params
  })
}

// 获取搜索结果接口search
export const searchResult = (params) => {
  return request({
    method: 'GET',
    url: '/app/v1_0/search',
    params
  })
}

// 获取用户搜索历史  /app/v1_0/search/histories

export const getHistories = () => {
  return request({
    method: 'GET',
    url: '/app/v1_0/search/histories'
  })
}

// 获取文章详情的接口  /app/v1_0/articles/:article_id

export const getArticleDetails = (article_id) => {
  return request({
    method: 'GET',
    url: `/app/v1_0/articles/${article_id}`
  })
}
